<template>
    <div>
        <router-view></router-view>
        <Spin size="large" fix v-if="this.$store.state.Administrator.EventList === null || !this.$store.state.AllDept === null"></Spin>
    </div>
</template>

<script>
export default {
    methods: {
        /**
         *  设置建议流列表
         */
        async setEvent() {
            const State = this.$store.state
            let EventList = await this.$store.dispatch('getEvent', {
                userId: State.userInfo.USER_ID,
                event_id: this.event_id
            })
            this.$store.commit('SET_EventList', EventList.result)
        },
        /**
         *  设置学校一级单位
         */
        async setAllDept() {
            let AllDept = await this.$store.dispatch('getAllDept')
            this.$store.commit('SET_AllDept', AllDept.result)
        },
    },
    created() {
        this.$store.commit('SET_EventList', null)
        this.$store.commit('SET_AllDept', null)
        const Vm = this
        this.page = sessionStorage.getItem('page')
        this.event_id = sessionStorage.getItem('EVENT_ID')
        /**
         * 确认用户信息是否加载
         */
        function isUserInfo() {
            return new Promise((resolve, reject) => {
                let isu = setInterval(() => {
                    if (Vm.$store.state.userInfo) {
                        clearInterval(isu)
                        resolve()
                    }
                }, 100)
            })
        }
        /**
         * 执行步骤
         */
        async function Step() {
            Vm.setEvent()
            Vm.setAllDept()
            Vm.$store.commit('INIT_tsPepole')
        }
        isUserInfo().then(() => {
            Step()
        })
    }
}
</script>
